//
//  LzwNewTableTwoCell.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/1.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwNewTableTwoCell.h"
#import "LzwBaseImageView.h"
#import "LzwBaseLable.h"
#import "UIImageView+WebCache.h"


@interface LzwNewTableTwoCell ()

@property (nonatomic, retain) LzwBaseImageView *myImageTwo;
@property (nonatomic, retain) LzwBaseImageView *myImageTwo1;
@property (nonatomic, retain) LzwBaseLable *mylable;
@property (nonatomic, retain) LzwBaseLable *myLable2;

@end

@implementation LzwNewTableTwoCell

-(void)dealloc{
    [_myImageTwo release];
    [_myImageTwo1 release];
    [_mylable release];
    [_myLable2 release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatNewTwo];
    }
    return self;
}

- (void)creatNewTwo{
    
    //图片
    self.myImageTwo = [[LzwBaseImageView alloc]initWithFrame:CGRectMake(2 * WIDTH, 2 * WIDTH, 370 * WIDTH, 180 * WIDTH)];
    self.myImageTwo.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myImageTwo];
    
    //喜爱图片
    self.myImageTwo1 = [[LzwBaseImageView alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 70 * WIDTH, 230 * WIDTH, 20 * WIDTH, 20 * WIDTH)];
    
    self.myImageTwo1.image = [UIImage imageNamed:@"redLove.png"];
    [self.contentView addSubview:self.myImageTwo1];
    
    //描述
    self.mylable = [[LzwBaseLable alloc]initWithFrame:CGRectMake(2 * WIDTH, 185 * WIDTH, 369 * WIDTH, 45 * WIDTH)];
    self.mylable.textColor = [UIColor lightGrayColor];
    self.mylable.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.mylable.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.mylable];
    
    //喜爱人数
    self.myLable2 = [[LzwBaseLable alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 50 + 5 * WIDTH, 230 * WIDTH, 60 * WIDTH, 20 * WIDTH)];
    self.myLable2.textColor = [UIColor lightGrayColor];
    self.myLable2.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLable2.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLable2];
    
    
}

- (void)setModleTwo:(LzwModleNewTwo *)modleTwo{
    
    if (_modleTwo != modleTwo) {
        [_modleTwo release];
        _modleTwo = [modleTwo retain];
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        
        NSURL *url = [NSURL URLWithString:modleTwo.pic];
    
    [self.myImageTwo sd_setImageWithURL:url placeholderImage:nil];

    self.mylable.text = self.modleTwo.title;
    
    self.myLable2.text = self.modleTwo.likes;
        
        });
}

@end
